//2009/09/07 22:15:44
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class InstantRunoff
{
public:
    string outcome(string candidates, vector <string> ballots)
    {
        int N = candidates.size();
        int M = ballots.size();
        vector<bool> visit(26, false);
        for(int i=0; i<N; i++)
        {
        	int idx = candidates[i] - 'A';
        	visit[idx] = true;
        }
        int cnt = N;
        while(true)
        {
        	vector<int> v(26, 0);
        	for(int i=0; i<M; i++)
        	{
        		for(int j=0; j<N; j++)
        		{
        			int idx = ballots[i][j] - 'A';
        			if(visit[idx])
        			{
        				v[idx]++;
        				break;
        			}
        		}
        	}
        	int mmin = 1<<20;
        	for(int i=0; i<26; i++)
        	{
        		if(visit[i])
        		{
        			if(2*v[i] > M)
        			{
        				string s;
        				s += 'A'+i;
        				return s;
        			}
        			else mmin = min(mmin, v[i]);
        		}
        	}
        	for(int i=0; i<26; i++)
        	{
        		if(visit[i])
        		{
        			if(mmin == v[i])
        			{
        				visit[i] = false;
        				cnt--;
        			}
        		}
        	}
        	if(cnt == 0) return "";
        }
    }
};
